Repository navigation
bench.sh: runtime and implementation apart, h2v2 on COROSIO, closed-stream fix - #49
Merged
Merged
Conversation
When a connection ends, the send loop closes the streams that are left and do_session() deletes the nghttp2 connection, setting conn to nullptr. A handler that is yet to submit its response can still hold such a stream, and async_submit() checked only that the stream existed, so it handed nghttp2 a null conn. On ASIO the handler happened to resume while end_connection() still ran and nghttp2 merely refused the closed stream; on COROSIO it resumes after, and the server crashed in nghttp2_conn_submit_response. A closed stream now completes the submit with connection_aborted, as nghttp2's refusal did, and read_callback() no longer extends the window of a closed stream, whose rest of the body may be read after the connection is gone. Found with scripts/bench.sh -2 -P -i -t 40 -u /test/data/64kminus1, h2load cutting off the responses at the end of the run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build-corosio-h2v2-release/, so that bench.sh -2 has nghttp2 version 2 on both I/O runtimes, and build-corosio-h2v2-asan/, where the h2v2 crash on a closed stream showed under ASAN while build-h2v2-asan/ ran clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each row names the server program, its I/O runtime and the protocol implementation in columns of their own (anyhttp/nghttpd; asio, corosio, libev; beast, nghttp2, nghttp2v2, ngtcp2+nghttp3), instead of one "server" name that folded runtime and implementation together, which left the h2v2 row unclear about its runtime. -2 now runs the nghttp2 version 2 build of both runtimes. On a terminal the runtimes are in colour (asio blue, corosio orange, nghttpd grey), and so are the implementations and the ratios that differ from asio by more than 5%. NO_COLOR turns that off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same guards as h2v2's: when the connection ends, nghttp2 closes the streams that are left and do_session() deletes the session, while a handler that is yet to submit can still hold one of them. async_submit() then handed nghttp2_submit_response2() a stream nghttp2 no longer knew -- or a null session -- and, ignoring the refusal, told the handler it had succeeded. A closed stream now completes the submit with connection_aborted, as on h2v2, and read_callback() no longer consumes on a closed stream. Also aligns h2/ with h2v2/ where they had drifted apart: goaway_sent_ moves to where h2v2 has it, and the stream's unused pending and unhandled go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge of master took this branch's table, which has a format of its own for the data rows, and so lost the 11 columns of 693f381. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
anyhttp/nghttpd;asio/corosio/libev;beast,nghttp2,nghttp2v2,ngtcp2+nghttp3). It used to have a single "server" column, so theh2v2row didn't say which runtime it ran on.-2now runs the nghttp2 version 2 build on both runtimes. On a terminal the output is in colour: asio blue, corosio orange, nghttpd grey, and ratios green or red when they differ from asio by more than 5%.NO_COLORturns colour off.build-corosio-h2v2-release(forbench.sh -2) andbuild-corosio-h2v2-asan.The crash
Found with
scripts/bench.sh -2 -P -i -t 40 -u /test/data/64kminus1: the COROSIO + nghttp2v2 server segfaulted innghttp2_conn_submit_responsewithconn == nullptrwhen h2load cut off the 64 KiB responses at the end of the run.When a connection ends, the send loop closes the streams that are left and
do_session()deletes the nghttp2 connection. A handler that hasn't sent its response yet can still hold one of those streams.async_submit()checked only that the stream existed, not that it was closed. On ASIO the handler happened to resume whileend_connection()was still running, so nghttp2 still existed and just refused the closed stream. On COROSIO the handler resumed after the connection was gone. ASAN reported a read of the zero page, not a use-after-free;build-h2v2-asan(ASIO) ran clean.Now a closed stream makes
async_submit()fail withconnection_aborted, andread_callback()no longer extends the receive window of a closed stream. Version 1 has the same unguarded code and gets the same two guards. One behaviour change there: v1 ignored nghttp2's refusal and told the handler the submit had succeeded; now it reportsconnection_aborted, as h2v2 does.Alignment of h2/ with h2v2/:
goaway_sent_moves to the same place in the member list, and two unused stream members (pending,unhandled) are removed. Everything else that differs comes from the two nghttp2 APIs themselves.Testing
test_allpasses onbuild,build-corosio,build-h2v2,build-corosio-h2v2-releaseandbuild-corosio-h2v2-asan(gtest-parallel).scripts/check_package.sh(noCMakeLists.txtor public header changed) and the TLS variant (ANYHTTP_TEST_SCHEME=https).🤖 Generated with Claude Code